import { createStore } from 'vuex';


import menu from './modules/menu/index';
import role from './modules/role/index';
import user from './modules/user/index';
import cate from './modules/cate/index';
import specs from './modules/specs/index';
import goods from './modules/goods';
interface StateUser {
  userInfo: any
}
export default createStore({
  state: {
    userInfo: sessionStorage.getItem('userInfo') ? JSON.parse(sessionStorage.getItem('userInfo') as any) : null
  },
  getters: {
    getUserInfo(state: StateUser) {
      return state.userInfo;
    }
  },
  mutations: {
    USER_INFO(state: StateUser, payload) {
      state.userInfo = payload;
      // 将用户信息存储在本地
      sessionStorage.setItem('userInfo', JSON.stringify(payload));
    }
  },
  actions: {
  },
  modules: {
    menu, role, user,cate,specs,goods
  }
})
